package com.dqhl.community.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dqhl.community.R;
import com.dqhl.community.model.CouponsUseInfo;
import com.dqhl.community.util.ViewHolder;

import java.util.List;

/**
 * Created by cheng on 2016/9/2.
 * 优惠券使用情况列表 adapter
 */
public class CouponsListAdapter extends BaseAdapter {

    private Context context;
    private List<CouponsUseInfo> couponsUseInfoList;
    private LayoutInflater inflater;

    public CouponsListAdapter(Context context, List<CouponsUseInfo> couponsUseInfoList) {
        this.context = context;
        this.couponsUseInfoList = couponsUseInfoList;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return couponsUseInfoList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.lv_item_coupons_info, parent, false);
        }
        TextView tvDate = ViewHolder.get(convertView, R.id.tv_date);
        TextView tvShopName = ViewHolder.get(convertView, R.id.tv_shop_name);
        TextView tvDetails = ViewHolder.get(convertView, R.id.tv_details);
        TextView tvUseTag = ViewHolder.get(convertView, R.id.tv_use_tag);

        CouponsUseInfo couponsUseInfo = couponsUseInfoList.get(position);
        tvDate.setText(couponsUseInfo.getTime());
        tvShopName.setText(couponsUseInfo.getShop_name());
        tvDetails.setText(couponsUseInfo.getDetails());
        tvUseTag.setText(couponsUseInfo.getTag());

        return convertView;
    }
}
